package test3_21.demo01;
/*
定义PayrollSystem类，创建Employee变量数组并初始化，该数组存放各类雇员对象的引用。
利用循环结构遍历数组元素，输出各个对象的类型,name,number,birthday,以及该对象生日。
当键盘输入本月月份值时，如果本月是某个Employee对象的生日，还要输出增加工资信息。
 */
import java.util.Scanner;
public class PayrollSystem {
    public static void main(String[] args) {
        Employee[] arr = new Employee[3];
        arr[0] = new SalariedEmployee("tom",1,new MyDate(2000,4,4),10000);
        arr[1] = new HourlyEmployee("jack",2,new MyDate(2001,2,7),11,10);
        arr[2] = new SalariedEmployee("mike",3,new MyDate(1999,3,23),11000);

        for(Employee a : arr){
            System.out.println(a.tostring());
        }

        Scanner sc = new Scanner(System.in);
        System.out.println("输入本月月份:");
        int month = sc.nextInt();


        boolean hasBirthday = false;
        for (int i = 0; i < arr.length; i++) {
            if(month == arr[i].getBirthMonth()){
                System.out.println("此月有人生日");
                double salary = arr[i].earnings() + 100;
                System.out.println(arr[i].getName()+"工资加100，本月工资为："+ salary);
                hasBirthday = true;
            }
        }

        if (hasBirthday != true){
            System.out.println("没人生日");
        }

    }
}
